#include <QtGui>
#include "b.h"
#include <iostream>

class Game;

 Canvas::Canvas(QWidget *parent)
     : QWidget(parent)
 {
     startButton = new QPushButton(tr("&Start"));
     hitButton = new QPushButton(tr("&Hit"));
     standButton = new QPushButton(tr("&Stand"));
     shuffleButton = new QPushButton(tr("&Shuffle"));

     connect(startButton, SIGNAL(clicked()), this, SLOT(startBtn()));
     connect(hitButton, SIGNAL(clicked()), this, SLOT(hitBtn()));
     connect(standButton, SIGNAL(clicked()), this, SLOT(standBtn()));
     connect(shuffleButton, SIGNAL(clicked()), this, SLOT(shuffleBtn()));

     QHBoxLayout *buttonLayout = new QHBoxLayout;
     buttonLayout->addWidget(startButton);
     buttonLayout->addWidget(hitButton);
     buttonLayout->addWidget(standButton);
     buttonLayout->addWidget(shuffleButton);
     buttonLayout->addStretch();

     QGraphicsView *graphicsView = new QGraphicsView;

     QVBoxLayout *verticalLayout = new QVBoxLayout;
     verticalLayout->addLayout(buttonLayout);
     verticalLayout->addWidget(graphicsView);
     hostState = new QLabel("host");
     playerState = new QLabel("player");
     cout << "hostState =" << hostState << endl;
     cout << "playerState =" << playerState << endl;
     result = new QLabel("result");
     verticalLayout->addWidget(hostState);
     verticalLayout->addWidget(playerState);
     verticalLayout->addWidget(result);

     QGridLayout *mainLayout = new QGridLayout;

     mainLayout->addLayout(verticalLayout, 0,0,1,1);

     setLayout(mainLayout);
     setWindowTitle(tr("Simple Black"));
     cout << "Canvas::Canvas" << endl;
 }

void Canvas::startBtn()
{
/*
        std::cout << "start() state = " << hostState << std::endl;
	hostState->setText(tr("start btn"));
  	startGame(this);
*/
        cout << "startBtn()" << endl;
    	vector<string> names;
    	string name = "You";
    	names.push_back(name);

    	//the game 
    	myGame = new Game(names,this);
        cout << "myGame=" << myGame << endl;

    	// initial table setup
    	myGame->setupTable();
}

void Canvas::hitBtn()
{
	cout << "hitBtn()" << endl;
	myGame->hitSelected();
}

void Canvas::standBtn()
{
        std::cout << "stand() state = " << hostState << std::endl;

}

void Canvas::shuffleBtn()
{
}

void Canvas::setHostStateLabel(QString &s)
{
        std::cout << " Canvas::setHostStateLabel() " << std::endl;
        std::cout << "state=" << hostState << std::endl;
	hostState->setText(s);
}

void Canvas::setPlayerStateLabel(QString &s)
{
        std::cout << " Canvas::setPlayerStateLabel() " << std::endl;
        std::cout << "state=" << playerState << std::endl;
	playerState->setText(s);
}

void Canvas::setResultLabel(QString &s)
{
        std::cout << " Canvas::setResultLabel() " << std::endl;
        std::cout << "state=" << result << std::endl;
	result->setText(s);
}



